package com.hs.srm.admin.modules.pricemanagement.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hs.srm.admin.modules.pricemanagement.dao.InquiryHeaderDao;
import com.hs.srm.admin.modules.pricemanagement.entity.InquiryHeaderEntity;
import com.hs.srm.admin.modules.pricemanagement.service.InquiryHeaderService;
import com.hs.srm.admin.modules.pricemanagement.vo.InquiryHeaderVO;
import com.hs.srm.base.common.annotation.DataFilter;
import com.hs.srm.base.common.utils.Constant;
import com.hs.srm.base.common.utils.QueryParam;
import com.hs.srm.common.utils.PageUtils;
/**
 * @author yanfei
 *
 * @date 2019年3月1日
 * 询价单头信息
 */
@Service("inquiryHeaderService")
public class InquiryHeaderServiceImpl  extends ServiceImpl<InquiryHeaderDao, InquiryHeaderEntity>   implements InquiryHeaderService {
    
	@Override
	@DataFilter
	public PageUtils queryPage(Map<String, Object> params) {
		//汇总号
		String inquiryTotalCode = (String)params.get("inquiryTotalCode");
		//状态
		Integer state=null;
		if(StringUtils.isNotBlank((String) params.get("state"))){
			state = Integer.parseInt((String) params.get("state"));
		}
		Page<InquiryHeaderEntity> page = this.selectPage(
				new QueryParam<InquiryHeaderEntity>(params).getPage(),
				new EntityWrapper<InquiryHeaderEntity>()
						.like(StringUtils.isNotBlank(inquiryTotalCode), "inquiry_total_code", inquiryTotalCode)
						.eq(state!=null,"state",state)
						.orderBy("begin_date", false)
						.orderBy("inquiry_total_code",false)
		);
		return new PageUtils(page);
	}
    
	@Override
	public int selectversion() {
		return this.baseMapper.selectversion();
	}

	@Override
	public String selectnum() {
		return this.baseMapper.selectnum();
	}

	
	@Override
	public InquiryHeaderEntity findByNo(String inquiryTotalCode) {
		
		return this.baseMapper.findByNo(inquiryTotalCode);
	}
	
	
	@Override
	public List<InquiryHeaderVO> selectBatchIds(List<String> ids) {
		
		return this.baseMapper.selectBatchIds(ids);
	}

}
